<div class="right_box">
  <el-row>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色列表</el-breadcrumb-item>
    </el-breadcrumb>
  </el-row>

  <el-row class="add_box">
    <el-button @click="() => this.addRolesDialog = true" type="waring">添加角色</el-button>
  </el-row>

  <el-row class="rolesList_box">
    <el-table
    :data="rolesList"
    style="width: 100%">
      <el-table-column type="expand">
        <template slot-scope="data">
          <el-row class="first" v-for="first in data.row.children" :key="first.id">
            <el-col :span="4">
              <el-tag @close="deleteRightHandler(data.row.id, first.id)" closable>{{ first.authName }}</el-tag>
            </el-col>
            <el-col :span="20">
              <el-row class="second" v-for="second in first.children" :key="second.id">
                <el-col :span="4">
                  <el-tag @close="deleteRightHandler(data.row.id, second.id)" closable type="warning">{{ second.authName }}</el-tag>
                </el-col>
                <el-col :span="20">
                  <el-col class="third" v-for="third in second.children" :key="third.id" :span="4">
                    <el-tag @close="deleteRightHandler(data.row.id, third.id)" closable type="success">{{ third.authName }}</el-tag>
                  </el-col>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
        </template>
      </el-table-column>
      <el-table-column
        label="序号"
        type="index"
        width="70">
      </el-table-column>
      <el-table-column
        label="角色名称"
        prop="roleName"
        width="120">
      </el-table-column>
      <el-table-column
        label="角色描述"
        prop="roleDesc"
        width="200">
      </el-table-column>
      <el-table-column
      label="操作">
      <template slot-scope="data">
        <el-tooltip class="item" effect="dark" content="编辑" placement="left">
          <el-button @click="showEditInfoDialog(data.row)" icon="el-icon-edit" size="mini" type="success" circle></el-button>
        </el-tooltip>
        <el-tooltip class="item" effect="dark" content="删除" placement="top">
          <el-button @click="deleteRolesHandler(data.row.id)" icon="el-icon-delete" size="mini" type="danger" circle></el-button>
        </el-tooltip>
        <el-tooltip class="item" effect="dark" content="分配权限" placement="right">
          <el-button @click="showEditRightsHandler(data.row.children, data.row.id)" icon="el-icon-setting" size="mini" type="primary" circle></el-button>
        </el-tooltip>
      </template>
    </el-table-column>
    </el-table>
  </el-row>

  <el-dialog @closed="closeAddRolesDialog" title="添加角色" :visible.sync="addRolesDialog">
    <el-form ref="addRoles" :rules="addRolesRules" :model="addRolesInfo">
      <el-form-item label="角色名称" prop="roleName" label-width="800">
        <el-input v-model="addRolesInfo.roleName" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="角色描述" prop="roleDesc" label-width="800">
        <el-input v-model="addRolesInfo.roleDesc" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <!-- 点击取消按钮的时候, 关闭对话框 -->
      <el-button @click="() => this.addRolesDialog = false">取 消</el-button>
      <!-- 点击确认添加角色按钮 -->
      <el-button @click="addRolesHandler" type="success">添加角色</el-button>
    </div>
  </el-dialog>

  <el-dialog title="编辑角色" :visible.sync="editRolesInfoDialog">
    <el-form ref="addRoles" :rules="addRolesRules" :model="editRolesInfo">
      <el-form-item label="角色名称" prop="roleName" label-width="800">
        <el-input v-model="editRolesInfo.roleName" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="角色描述" prop="roleDesc" label-width="800">
        <el-input v-model="editRolesInfo.roleDesc" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <!-- 点击取消按钮的时候, 关闭对话框 -->
      <el-button @click="() => this.editRolesInfoDialog = false">取 消</el-button>
      <!-- 点击确认编辑按钮的时候, 发送请求修改内容 -->
      <el-button @click="editRolesInfoHandler" type="success">确认编辑</el-button>
    </div>
  </el-dialog>

  <el-dialog @closed="closeRightsDialog" title="分配权限" :visible.sync="editRightsDialog">
    <el-tree
      ref="rightsTree"
      v-if="editRightsDialog"
      :data="rightsList"
      show-checkbox
      node-key="id"
      :default-expanded-keys="expendRightsList"
      :default-checked-keys="checkedRightsList"
      :props="rightsTreeInfo">
    </el-tree>

    <div slot="footer" class="dialog-footer">
      <el-button @click="() => this.editRightsDialog = false">取 消</el-button>
      <el-button @click="editRightHandler" type="success">确认权限分配</el-button>
    </div>
  </el-dialog>
</div>
